package com.qhy.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qhy.pojo.TbComments;
import com.qhy.service.ICommentsService;


@Controller
@RequestMapping("comment")
public class CommentController {
	
	@Resource
	private ICommentsService service;
	
	
	@RequestMapping("queryAll.do")
	public String queryAll(@RequestParam(defaultValue="1",required = true) Integer tr,HttpServletRequest request) {
		PageHelper.startPage(tr, 3);
		PageInfo<TbComments> page = new PageInfo<TbComments>(service.queryAll());
		request.setAttribute("p", page);
		
		
		return "comment";
	}
	
	@RequestMapping("delete.do")
	public String delete(Integer cm_id) {
		service.delete(cm_id);
		return "forward:/comment/queryAll.do";
	}
	
	@RequestMapping("queryByPsId.do")
	public String queryByPsId(HttpServletRequest request,Integer psId) {
		request.setAttribute("pro_comment", service.queryByPsId(psId));
		return "product-info3";
	}
	
	
}
